package com.jv.spring.importresource.scan;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;

@Component
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
	@Override
	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
		BeanDefinition dept = beanFactory.getBeanDefinition("dept");
		//dept.setAutowireCandidate(false);

		/*
		//网上说是在依赖注入之前调用@PostConstruct修饰的方法，原来是错的
		Dept deptObject = (Dept)beanFactory.getSingleton("dept");
		System.out.println(deptObject.getCity());
		*/
		dept.setInitMethodName("initMethod");
	}
}
